package com.xinchuang.domain.pojo;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>
 *
 * </p>
 *
 * @author zx
 * @since 2023-07-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class TestNoticeConsumableTable implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 标识ID
     */
    @TableId
    private String consumptionId;

    /**
     * 通知单ID
     */
    private String parentNoticeId;

    /**
     * 类型
     */
    private String type;

    /**
     * 规格
     */
    private String specification;

    /**
     * 计量单位
     */
    private String measurement;

    /**
     * 领用数
     */
    private String claim;

    /**
     * 退库数
     */
    private String stock;

    /**
     * 消耗数
     */
    private String consumption;

    /**
     * 异常说明
     */
    private String description;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @Override
    public String toString() {
        String status = "";
        switch (type) {
            case "1":
                status = "材料";
                break;
            case "2":
                status = "纸箱";
                break;
            case "3":
                status = "包装袋";
                break;
            default:
                break;
        }
        StringBuffer buffer = new StringBuffer();
        if (StringUtils.isNotBlank(specification)) {
            buffer.append("规格=" + specification + ";");
        }
        if (StringUtils.isNotBlank(claim)) {
            buffer.append("领用数=" + claim + ";");
        }
        if (StringUtils.isNotBlank(stock)) {
            buffer.append("退库数=" + stock + ";");
        }
        if (StringUtils.isNotBlank(consumption)) {
            buffer.append("消耗数=" + consumption + ";");
        }
        if (StringUtils.isNotBlank(description)) {
            buffer.append("异常说明=" + description + ";");
        }
        if (buffer.length() > 0) {
            return "TestNoticeConsumableTable{" + "类型=" + status + ";" + buffer.toString() + "}";
        }
        return null;
    }

    /**
     *  自定义比较方法，根据 type 和 specification 判断相等性
     * @param other
     * @return
     */
    public boolean isEqualTo(TestNoticeConsumableTable other) {
        return this.type.equals(other.getType()) && this.specification.equals(other.getSpecification());
    }
}
